<?  layout("../layout/default.html") { ?>
<div class="admin-panel">
	<div class="tab">
		<div class="tab-head">
			<strong> <? if(@data.isNew()){ ?>添加<? }else{ ?>编辑<?} ?>
			</strong> <span class="tab-more"><a href="javascript:history.go(-1)"
				class="button  button-little bg-blue  icon-step-backward"> 返回</a></span>
			<ul class="tab-nav">
				<li class="active"><a href="#tab-set">信息</a></li>
			</ul>
		</div>
		<div class="tab-body">
			<script type="text/javascript">
				function check() {
					var str0 = document.getElementById("equipment_name").value;
					var str1 = document.getElementById("equipment_room_id").value;
					var str2 = document.getElementById("equipment_num_in_romm").value;
					var str3 = document.getElementById("equipment_panel_id").value;
					var str4 = document.getElementById("equipment_logic_id").value;
					var str4 = document.getElementById("equipment_scene_name").value;
					var reg = /[^\u4E00-\u9FA5]/;
					if (str0.length > 20) {
						alert("对不起，输入名称过长");
						document.getElementById("equipment_name").value = "";
						return false;
					}
					if (str1.length > 20) {
						alert("对不起，输入房间号过长");
						document.getElementById("equipment_room_id").value = "";
						return false;
					}
					if (str2.length > 20) {
						alert("对不起，输入设备序号过长");
						document.getElementById("equipment_num_in_romm").value = "";
						return false;
					}
					if (str3.length > 20) {
						alert("对不起，输入面板序号过长");
						document.getElementById("equipment_panel_id").value = "";
						return false;
					}
					if (str0.length == 0) {
						alert("设备名称不能为空");
						document.getElementById("equipment_name").value = "";
						return false;
					}
					if (str4.length == 0) {
						alert("逻辑id不能为空");
						document.getElementById("equipment_logic_id").value = "";
						return false;
					}
					if (str5.length == 0) {
						alert("所在区域不能为空");
						document.getElementById("equipment_scene_name").value = "";
						return false;
					}
				}
			</script>
			<div class="tab-panel active" id="tab-set">
				<form method="post" class="form-x" action="">
					<div class="form-group">
						<div class="label">
							<label for="sitename">名称</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_name"
								name="equipment.name" size="200" placeholder="请填写名称"
								data-validate="required:请填写名称" value="${data.name!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">逻辑序号</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_logic_id"
								name="equipment.logic_id" size="200" readonly="readonly"
								value="${data.logic_id!" "}"/>
						</div>
					</div>
					<div class="form-group">
                        <div class="label">
                            <label for="sitename">消息模板</label>
                        </div>
                        <div class="field">
                            <div class="selected-inline selected">
                                <select class="selected-inline selected "
                                    id="equipment_devicetype" name="equipment.devicetype">
                                </select>
                            </div>
                        </div>
                    </div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">所在区域</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_scene_name"
								name="equipment.scene_name" size="200" placeholder="请填写名称"
								data-validate="required:请填写名称" value="${data.scene_name!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">所在房间号</label>
						</div>
						<div class="field">
							<div class="selected-inline selected">
								<select class="selected-inline selected "
									name="equipment.room_id" id="equipment_room_id">
								</select>
							</div>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">房内设备序号</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_num_in_romm"
								name="equipment.num_in_room" size="200" placeholder="请填写房内设备序号"
								data-validate="required:请填写房内设备序号" value="${data.num_in_room!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">所在面板号</label>
						</div>
						<div class="field">
							<div class="selected-inline selected">
								<select class="selected-inline selected "
									id="equipment_panel_id" name="equipment.panel_id">
								</select>
							</div>
						</div>
					</div>

					<div class="form-group">
						<div class="label">
							<label for="sitename">设备状态</label>
						</div>
						<div class="field">
							<div class="selected-inline selected">
								<select class="selected-inline selected " id="equipment_status"
									name="equipment.status">
									<option value=1>工作</option>
									<option value=2>待机</option>
									<option value=3>保修</option>
								</select>
							</div>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">设备类型</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_type"
								name="equipment.type" size="200" placeholder="请填写设备类型"
								data-validate="required:请填写设备类型" value="${data.param5!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">设备参数1</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_param1"
								name="equipment.param1" size="200" placeholder="请填写设备参数"
								value="${data.param1!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">设备参数2</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_param2"
								name="equipment.param2" size="200" placeholder="请填写设备参数"
								value="${data.param2!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">设备参数3</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_param3"
								name="equipment.param3" size="200" placeholder="请填写设备参数"
								value="${data.param3!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">设备参数4</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_param4"
								name="equipment.param4" size="200" placeholder="请填写设备参数"
								value="${data.param4!" "}"/>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label for="sitename">设备参数5</label>
						</div>
						<div class="field">
							<input type="text" class="input" id="equipment_param5"
								name="equipment.param5" size="200" placeholder="请填写设备参数"
								value="${data.param5!" "}"/>
						</div>
					</div>
					<div class="form-button">
						<button class="button bg-main" type="submit"
							onclick="return check()">提交</button>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>
<?  } ?>
<script type="text/javascript">
	$(document).ready(
			function() {
				$.get("${root}/Equipment/getRoom", function(json) {
					var datas = eval(json);
					for (var i = 0; i < datas.length; i++) {
						$("#equipment_room_id").append(
								"<option value="+datas[i]+">" + datas[i]
										+ "</option>");
					}
				}, 'JSON');
				$.get("${root}/Equipment/getdevicetype", function(json) {
                    var datas = eval(json);
                    for (var i = 0; i < datas.length; i++) {
                        $("#equipment_devicetype").append(
                                "<option value="+datas[i]+">" + datas[i]
                                        + "</option>");
                    }
                }, 'JSON');
				$.get("${root}/Equipment/getPanel", function(json) {
					var datas = eval(json);
					for (var i = 0; i < datas.length; i++) {
						$("#equipment_panel_id").append(
								"<option value="+datas[i]+">" + datas[i]
										+ "</option>");
					}
				}, 'JSON');
			});
</script>
